{template 'common/header'}
{template 'common'}
<div class="main">
	<ul class="nav nav-tabs">
		<li{if $_GPC['do'] == 'manage'} class="active"{/if}><a href="{php echo $this->createWebUrl('manage');}">活动管理</a></li>
		<li{if $_GPC['do'] == 'post'} class="active"{/if}><a href="{php echo create_url('rule/post',array('module'=>'ewei_comeon'));}">添加活动规则</a></li>
		<li{if $_GPC['do'] == 'fanslist'} class="active"{/if}><a href="{php echo $this->createWebUrl('fanslist',array('name'=>'ewei_comeon', 'rid' => $rid));}">参与用户</a></li>
	</ul>
	
	   <div class="panel panel-info">
	<div class="panel-heading">筛选</div>
	<div class="panel-body">
		<form action="./index.php" method="get" class="form-horizontal" role="form">
			<input type="hidden" name="c" value="site" />
			<input type="hidden" name="a" value="entry" />
        	<input type="hidden" name="m" value="ewei_comeon" />
        	<input type="hidden" name="do" value="fanslist" />
        	<input type="hidden" name="rid" value="{$_GPC['rid']}" />
			<div class="form-group">
				<label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label">关键字</label>
				<div class="col-sm-8 col-lg-9">
					<input class="form-control" name="keywords" id="" type="text" value="{$_GPC['keywords']}" placeholder="可查询手机号"> 
				</div>
                          
			</div>
				<div class="form-group">
				<label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label">状态</label>
				<div class="col-sm-8 col-lg-9">
					<select name="status" class="form-control" style="float:left">
                                        <option value="" {if $_GPC['status']==''}selected{/if}>全部</option>
                                        <option value="0" {if $_GPC['status']=='0'}selected{/if}>未中奖</option>
                                        <option value="1" {if $_GPC['status']=='1'}selected{/if}>已中奖</option>
                                        <option value="2" {if $_GPC['status']=='2'}selected{/if}>已领奖</option>
                                    </select>
				</div>
                                <div class=" col-xs-12 col-sm-2 col-lg-2">
					<button class="btn btn-default"><i class="fa fa-search"></i> 搜索</button>
				</div>
			</div>
			
 			<div class="form-group">
			</div>
		</form>
	</div>
	
	 
		<div style="padding: 0 15px 0  15px;">
		  <div class="row-fluid">
                                <div class="span8 control-group">
                                    <a class="btn btn-default" href="{php echo $this->createWebUrl('download',array('rid'=>$rid))}"><i class="icon-download-alt"></i>导出用户信息</a>
                                    <a class="btn btn-default" href="{php echo $this->createWebUrl('fanslist',array('rid'=>$rid))}">全部</a>
                                    <a class="btn btn-default" href="{php echo $this->createWebUrl('fanslist',array('rid'=>$rid,'status'=>0))}">未中奖</a>
                                    <a class="btn btn-default" href="{php echo $this->createWebUrl('fanslist',array('rid'=>$rid,'status'=>1))}">已中奖</a>
                                    <a class="btn btn-default" href="{php echo $this->createWebUrl('fanslist',array('rid'=>$rid,'status'=>2))}">已领奖</a>
                                </div>
                            </div>
 
		</div>
	<div style="padding: 0 15px 0  15px;" style="position:relative">
		<table class="table table-hover" style="position:relative">
			<thead class="navbar-inner">
				<tr><th>序号</th>
				<th>微信码</th>
                                                <th>手机号</th>
                                                <th>点数</th>
                                                <th>被助力数</th>
                                            
                                                <th>参与时间</th>
                                                    <th>状态</th>
                                                    <th>中奖的奖品</th>
                                                <th>领取的奖品</th>
                                                <th>领奖时间</th>
                                              
                                                <th>操作</th>
		</tr>
			</thead>
			<tbody>
				{loop $list $row}
				<tr>
				<td>{$row['id']}</td>
				 <td>{$row['from_user']}</td>
				<td>{$row['mobile']}</td>
                                                <td>
                                                    <span class='points' style='cursor:pointer'>
                                                          <span class='points_num'>{$row['points']}</span>
                                                           <input type='text' class='form-control col-lg-1 points_input span1'  style="display:none" value='{$row['points']}' fansid='{$row['id']}' rid="{$row['rid']}"/>
                                                    </span> 
                                                
                                                </td>
                                                 <td><span class='helps' style='cursor:pointer'>
                                                          <span class='helps_num'>{$row['helps']}</span>
                                                           <input type='text' class='form-control col-lg-1 helps_input span1'  style="display:none" value='{$row['helps']}' fansid='{$row['id']}' rid="{$row['rid']}"/>
                                                    </span> </td>
                                              
                                               
                                                
                                               
                                                <td>{php echo date('Y/m/d H:i',$row['createtime']);}</td>
                                                <td>{if $row['status']==0}
                                                    <span class="label">未中奖</span>
                                                    {elseif $row['status']==1}
                                                    <span class="label label-warning">已中奖</span>
                                                    {else}
                                                    <span class="label label-success">已领奖</span>{/if}</td>
                                                <td>{loop $row['awardnames'] $r}
                                                    {$r['name']} /
                                                    {/loop}
                                                </td>
                                                <td>{$row['awardname']}</td>
                                                <td>{if $row['awardtime'] == 0}{else}{php echo date('Y/m/d H:i',$row['awardtime']);}{/if}</td>
                                                <td>
                                                    {if $row['status']!=2}
                                                  {loop $row['awardnames'] $r}
                                                  <a class="btn btn-default" href="#" onclick="drop_confirm('确认此用户领取{$r['name']}?','{php echo $this->createWebUrl('getaward',array('fansid'=>$row['id'],'id'=>$row['rid'], 'awardid'=>$r['id']))}');">领取{$r['name']}</a>
                                                  {/loop}
                                                  {else}
                                                  已领奖
                                                  {/if}
                                                           
                                                        </ul>
                                                    </div>
                                                </td>
				</tr>
				{/loop}
				
			</tbody>
		</table>
		{$pager}
	</div>
	
</div>
<script>

function drop_confirm(msg, url){
    if(confirm(msg)){
        window.location = url;
    }
}

$(function(){
    
    $(".points").click(function(){
          $(".points .points_num").show();
        $(".points .points_input").hide();
        var $this =$(this);
        var $p = $this.find('.points_num');
        
        var $i = $this.find('.points_input');
        $p.hide();
        $i.show();
        Tip.select($i, "输入数字点数，回车确认!","top");
        $i.keydown(function(event){  
                if(event.keyCode==13){  
                  if(!$i.isNumber()){
                        Tip.select($i, "请输入数字!","top");
                        return;
                  }
                    $p.show().html( $i.val() );
                      $i.hide();
                  $.post("{php echo $this->createWebUrl('points')}",{
                      rid: $i.attr("rid"),
                      fansid: $i.attr("fansid"),
                      points: $i.val()
                  },function(d){
                    
                  });
                }
            })
        
        
        
    })
    
     $(".helps").click(function(){
          $(".helps .helps_num").show();
        $(".helps .helps_input").hide();
        var $this =$(this);
        var $p = $this.find('.helps_num');
        
        var $i = $this.find('.helps_input');
        $p.hide();
        $i.show();
        Tip.select($i, "输入数字点数，回车确认!","top");
        $i.keydown(function(event){  
                if(event.keyCode==13){  
                  if(!$i.isNumber()){
                        Tip.select($i, "请输入数字!","top");
                        return;
                  }
                    $p.show().html( $i.val() );
                      $i.hide();
                  $.post("{php echo $this->createWebUrl('helps')}",{
                      rid: $i.attr("rid"),
                      fansid: $i.attr("fansid"),
                      helps: $i.val()
                  },function(d){
                    
                  });
                }
            })
        
        
        
    })
})
</script>
{template 'common/footer'}